<script setup lang="ts">
import { ref } from "vue";
import { ArrowDown, CaretBottom } from "@element-plus/icons-vue";
import Logo from "../assets/logo.svg";
import Flag from "../assets/flag.svg";
import Bell from "../assets/bell.svg";
import Avatar from "../assets/avatar.svg";

const activeIndex = ref("1");
const handleSelect = (key: string, keyPath: string[]) => {
  console.log(key, keyPath);
};
</script>

<template>
  <div class="nav">
    <div class="nav-logo">
      <img :src="Logo" />
    </div>
    <div class="nav-menu">
      <el-scrollbar>
        <el-menu
          :ellipsis="false"
          :default-active="activeIndex"
          class="el-menu-demo"
          mode="horizontal"
          @select="handleSelect"
          style="--el-menu-horizontal-height: 64px"
        >
          <el-menu-item index="1">主页</el-menu-item>
          <el-menu-item index="2">产品</el-menu-item>
          <el-menu-item index="3">订单</el-menu-item>
          <el-menu-item index="4">采购</el-menu-item>
          <el-menu-item index="5">仓储</el-menu-item>
          <el-menu-item index="6">物流</el-menu-item>
          <el-menu-item index="7">统计</el-menu-item>
          <el-menu-item index="8">设置</el-menu-item>
        </el-menu>
      </el-scrollbar>
    </div>
    <div class="nav-avatar">
      <el-dropdown>
        <span class="el-dropdown-link el-dropdown-link__locale">
          <img :src="Flag" style="margin-right: 8px" />中文
          <el-icon class="el-icon--right"><CaretBottom /></el-icon>
          <!-- <el-icon class="el-icon--right"><arrow-down /></el-icon> -->
        </span>
        <template #dropdown>
          <el-dropdown-menu>
            <el-dropdown-item>
              <img :src="Flag" style="margin-right: 8px" />
              中文
            </el-dropdown-item>
          </el-dropdown-menu>
        </template>
      </el-dropdown>
      <div style="position: relative; display: flex">
        <img :src="Bell" />
        <span class="point"></span>
      </div>
      <div class="avatar">
        <el-avatar :size="36" :src="Avatar" style="margin-right: 8px" />
        <el-dropdown>
          <span class="el-dropdown-link el-dropdown-link__userName">
            Fancy
            <el-icon class="el-icon--right"><CaretBottom /></el-icon>
            <!-- <el-icon class="el-icon--right"><arrow-down /></el-icon> -->
          </span>
          <template #dropdown>
            <el-dropdown-menu>
              <el-dropdown-item>退出登陆</el-dropdown-item>
            </el-dropdown-menu>
          </template>
        </el-dropdown>
      </div>
    </div>
  </div>
</template>

<style lang="scss" scoped>
.nav {
  display: flex;
  justify-content: space-between;
  .nav-logo {
    width: 220px;
    display: flex;
    align-items: center;
    flex-shrink: 0;
  }
  .nav-menu {
    flex: 1;
    overflow: hidden;
    .el-menu-item {
      border-bottom: none;
      font-family: PingFang SC;
      font-size: 14px;
      font-weight: 500;
      line-height: 24px;
      &:focus {
        background-color: #fff;
      }
      &.is-active {
        &::after {
          content: "";
          width: 28px;
          height: 2px;
          background: #4e0ada;
          position: absolute;
          bottom: 0;
          left: 50%;
          transform: translateX(-50%);
        }
      }
    }
  }
  .nav-avatar {
    width: 253px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    .el-dropdown-link {
      display: flex;
      align-items: center;
    }
    .el-dropdown-link__locale {
      font-family: Roboto;
      font-size: 13px;
      font-weight: 400;
      line-height: 15.23px;
      color: #202738;
    }
    .el-dropdown-link__userName {
      font-family: PingFang SC;
      font-size: 14px;
      font-weight: 400;
      line-height: 24px;
      color: #1e273a;
    }
    .point {
      background: #d25c49;
      width: 6px;
      height: 6px;
      border-radius: 50%;
      position: absolute;
      right: -6px;
      top: -3px;
    }
    .avatar {
      display: flex;
      align-items: center;
    }
  }
}
</style>
